﻿using Infrastructure.Attribute;
using ZR.Model;
using ZR.Model.System;
using ZR.Service;
using ZR.Service.System.IService;
using ZR.ServiceCore.Services.IService;

namespace ZR.ServiceCore.Services;

[AppService(ServiceType = typeof(IBaseCodeRuleService), ServiceLifetime = LifeTime.Transient)]
public class BaseCodeRuleService : BaseService<BaseCodeRule>, IBaseCodeRuleService
{
    public Task<int> InsertBaseCodeRuleAsync(BaseCodeRule baseCodeRule)
    {
        return Insertable(baseCodeRule).ExecuteCommandAsync();
    }

    public Task<int> DeleteBaseCodeRuleAsync(string code)
    {
        return Deleteable().Where(m => m.Code == code).ExecuteCommandAsync();
    }

    public Task<int> UpdateBaseCodeRule(BaseCodeRule baseCodeRule)
    {
        return Updateable(baseCodeRule).ExecuteCommandAsync();
    }

    public PagedInfo<BaseCodeRule> SelectBaseCodeRulePage(BaseCodeRule baseCodeRule, PagerInfo pager)
    {
        var exp = Expressionable.Create<BaseCodeRule>();
        return GetPages(exp.ToExpression(), pager);
    }
}